package com.example.parkingproject.controller;

import com.example.parkingproject.jopo.entity.Comment;
import com.example.parkingproject.result.JsonResult;
import com.example.parkingproject.service.CommentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@Slf4j
@RestController
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    CommentService commentService;

    @RequestMapping("/newComment")
    public JsonResult newComment(@RequestBody Comment comment) {
        commentService.newComment(comment);
        return JsonResult.ok();
    }

    @RequestMapping("/getCommentList")
    public JsonResult getCommentList(Integer locationNumber) {
        List<Comment> list = commentService.getCommentList(locationNumber);
        log.debug("获取的参数{}",list);
        return JsonResult.ok(list);
    }
}
